/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.annotations;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author WORKSPOT2
 */
public class AnnotationTest
{

    public static void main(String[] args)
    {
        CsvMechanism<Animal> csv = new CsvMechanism<Animal>(Animal.class);
        List<Animal> testList = new ArrayList<Animal>();
        testList.add(new Animal("animal1", "type1", "subtype1", true));
        testList.add(new Animal("animal2", "type2", "subtype2", true));
        testList.add(new Animal("animal3", "type3", "subtype3", false));
        String res = csv.convertToCsv(testList);
        System.out.println(res);
    }

    private static void test1()
    {
        try
        {
            User u1 = new User("Vasya", 1, "VasyaOK");
            Class cls = u1.getClass();
            Field fields[] = cls.getDeclaredFields();
            MyAnnotation tmp;
            System.out.println(u1);
            for (int i = 0; i < fields.length; i++)
            {
                tmp = fields[i].getAnnotation(MyAnnotation.class);
                if (tmp != null)
                {
                    String value = tmp.value();
                    fields[i].setAccessible(true);
                    fields[i].set(u1, Integer.parseInt(value));
                }
            }
            System.out.println(u1);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
